package com.ruoyi.project.yingyu.activitycheckin.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.utils.MoneyUtil;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.yingyu.activitycheckin.domain.ActivityCheckin;
import com.ruoyi.project.yingyu.activitycheckin.mapper.ActivityCheckinMapper;
import com.ruoyi.project.yingyu.activitycheckin.service.IActivityCheckinService;

/**
 * 活动签到Service业务层处理
 * 
 * @author shixiangwen
 * @date 2020-03-13
 */
@Service
public class ActivityCheckinServiceImpl implements IActivityCheckinService {
	@Autowired
	private ActivityCheckinMapper activityCheckinMapper;

	/**
	 * 查询活动签到
	 * 
	 * @param id 活动签到ID
	 * @return 活动签到
	 */
	@Override
	public ActivityCheckin selectActivityCheckinById(Long id) {
		return activityCheckinMapper.selectActivityCheckinById(id);
	}

	/**
	 * 查询活动签到列表
	 * 
	 * @param activityCheckin 活动签到
	 * @return 活动签到
	 */
	@Override
	public List<ActivityCheckin> selectActivityCheckinList(ActivityCheckin activityCheckin) {
		List<ActivityCheckin> list = activityCheckinMapper.selectActivityCheckinList(activityCheckin);
		list.forEach(item -> {
			item.setYuan(MoneyUtil.fee2yuan(item.getGainFee()).toString());
		});
		return list;
	}

	/**
	 * 新增活动签到
	 * 
	 * @param activityCheckin 活动签到
	 * @return 结果
	 */
	@Override
	public int insertActivityCheckin(ActivityCheckin activityCheckin) {
		return activityCheckinMapper.insertActivityCheckin(activityCheckin);
	}

	/**
	 * 修改活动签到
	 * 
	 * @param activityCheckin 活动签到
	 * @return 结果
	 */
	@Override
	public int updateActivityCheckin(ActivityCheckin activityCheckin) {
		return activityCheckinMapper.updateActivityCheckin(activityCheckin);
	}

	/**
	 * 删除活动签到对象
	 * 
	 * @param ids 需要删除的数据ID
	 * @return 结果
	 */
	@Override
	public int deleteActivityCheckinByIds(String ids) {
		return activityCheckinMapper.deleteActivityCheckinByIds(Convert.toStrArray(ids));
	}

	/**
	 * 删除活动签到信息
	 * 
	 * @param id 活动签到ID
	 * @return 结果
	 */
	@Override
	public int deleteActivityCheckinById(Long id) {
		return activityCheckinMapper.deleteActivityCheckinById(id);
	}
}
